package org.hot100_6.leetcode283;

public class Solution3 {


    public static void main(String[] args) {
        int[] nums = {1, 0, 2, 0, 3};
        moveZeroes(nums);
        for (int num : nums) {
            System.out.println(num);
        }
    }

    public static void moveZeroes(int[] nums) {
        int n = nums.length;
        int slow = 0;

        for (int fast = 0; fast < n; fast++) {
            if (nums[fast]!=0){
                nums[slow]=nums[fast];
                if (slow!=fast){
                    nums[fast]=0;
                }
                slow++;

            }
        }

    }
}
